package models

import (
	"context"
	"errors"
	"go.mongodb.org/mongo-driver/mongo"
	"go.mongodb.org/mongo-driver/mongo/options"
)

var (
	MongoDBDefault *mongo.Database
)

type Arr map[string]interface{}

//初始化mongodb
func MongoDbInit()  {
	// 建立mongodb连接
	clientOptions := options.Client().ApplyURI("mongodb://ichunt:huntmon6699@192.168.1.237:27017/ichunt?authMechanism=SCRAM-SHA-1")

	client, err := mongo.Connect(context.TODO(),clientOptions)
	if err != nil {
		panic(errors.New("mongodb 连接失败"))
	}

	// 2, 选择数据库my_db
	MongoDBDefault = client.Database("dahuang")
}
